<template>
  <div>
    <h1>配置中心</h1>
    <!-- 曲线配置curve -->
    <template>
        <el-checkbox class="checkedAll" :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">曲线配置</el-checkbox>
        <el-checkbox-group v-model="checkedCities" @change="handleCheckedCitiesChange">
            <el-checkbox v-for="city in cities" :label="city" :key="city">{{city}}</el-checkbox>
        </el-checkbox-group>
    </template>
    <!-- 区域配置area -->
    <template>
        <el-checkbox class="checkedAll" :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">曲线配置</el-checkbox>
        <el-checkbox-group v-model="checkedCities" @change="handleCheckedCitiesChange">
            <el-checkbox v-for="city in cities" :label="city" :key="city">{{city}}</el-checkbox>
        </el-checkbox-group>
    </template>
    <!-- 区块配置block -->
    <template>
        <el-checkbox class="checkedAll" :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">曲线配置</el-checkbox>
        <el-checkbox-group v-model="checkedCities" @change="handleCheckedCitiesChange">
            <el-checkbox v-for="city in cities" :label="city" :key="city">{{city}}</el-checkbox>
        </el-checkbox-group>
    </template>
    <!-- 曲线单位curveunit -->
    <template>
        <el-checkbox class="checkedAll" :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">曲线配置</el-checkbox>
        <el-checkbox-group v-model="checkedCities" @change="handleCheckedCitiesChange">
            <el-checkbox v-for="city in cities" :label="city" :key="city">{{city}}</el-checkbox>
        </el-checkbox-group>
    </template>
  </div>
</template>

<script>
const cityOptions = ['添加配置', '编辑配置', '删除配置'];
export default {
    data(){
        return {
            checkAll: false,
            checkedCities: [],
            cities: cityOptions,
            isIndeterminate: false
            
        }
    },
    methods: {
      handleCheckAllChange(val) {
        this.checkedCities = val ? cityOptions : [];
        this.isIndeterminate = false;
      },
      handleCheckedCitiesChange(value) {
        let checkedCount = value.length;
        this.checkAll = checkedCount === this.cities.length;
        this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length;
      }
    }
}
</script>

<style scoped>
  .checkedAll{
    margin:22px 0 8px 0;
  }
</style>